<%@ page import="com.alibaba.fastjson.JSON" %><%--
  Created by IntelliJ IDEA.
  User: DE
  Date: 2019/4/9
  Time: 17:47
  To change this template use File | Settings | File Templates.
--%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt_rt"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>个人中心</title>
    <link href="<%=basePath%>resources/layui/css/layui.css" rel="stylesheet"></link>
    <link href="<%=basePath%>resources/css/style.css" rel="stylesheet"></link>

    <style>
        .layui-fixbar{
            width: 40px;
        }

    </style>
</head>
<body>
 <!-- layout admin -->
 <div class="layui-layout layui-layout-admin"> <!-- 添加skin-1类可手动修改主题为纯白，添加skin-2类可手动修改主题为蓝白 -->
     <!-- header -->
     <div class="layui-header my-header">
         <a href="<c:if test="${user.usertype==1}"><%=basePath%>order/orderlist</c:if><c:if test="${user.usertype==0}"><%=basePath%>page/manager/orderManager</c:if>">
             <!--<img class="my-header-logo" src="" alt="logo">-->
             <div class="my-header-logo">校园便捷服务平台</div>
         </a>


         <!-- 顶部右侧添加选项卡监听 -->
         <ul class="layui-nav my-header-user-nav" lay-filter="side-top-right">
             <li class="layui-nav-item"><span id="datetime"></span>&nbsp;</li>
             <li class="layui-nav-item">
                 <a href="<c:if test="${user.usertype==1}"><%=basePath%>order/orderlist</c:if><c:if test="${user.usertype==0}"><%=basePath%>page/manager/orderManager</c:if>">主页</a>
             </li>
             <li class="layui-nav-item">
                 <a href="<%=basePath%>order/acceptOrderlist">我的订单<!--<span class="layui-badge">9</span>--></a>
             </li>
             <li class="layui-nav-item">
                 <a href="<%=basePath%>page/user/personalCenter">个人中心<!--<span class="layui-badge-dot"></span>--></a>
             </li>
             <li class="layui-nav-item">
                 <a href="<%=basePath%>page/user/personalCenter"><c:if test="${user.userimg!=null}"><img src="<%=basePath%>${user.userimg}" class="layui-nav-img"></c:if>${user.username}</a>
                 <dl class="layui-nav-child">
                     <dd><a href="javascript:;" onclick="logout()">退出系统</a></dd>
                 </dl>
             </li>
         </ul>

         <div class="layui-side my-side">
             <div class="layui-side-scroll">
                 <!-- 左侧主菜单添加选项卡监听 -->
                 <ul class="layui-nav layui-nav-tree layui-bg-black"  lay-filter="test">
                     <li class="layui-nav-item layui-nav-itemed layui-this">
                         <a class="" href="<%=basePath%>page/user/personalCenter">我的信息</a>
                     </li>
                     <li class="layui-nav-item">
                         <a href="<%=basePath%>page/user/personalPerformance">我的业绩</a>
                     </li>
                 </ul>


             </div>
         </div>
     </div>


     <!-- body -->
     <div class="layui-body my-body"  style="background-color: #F6F6F6">
         <div class="layui-tab-content">
             <div class=" layui-fluid">
                 <div class="layui-row">
                     <form class="layui-form layui-col12" lay-filter="orderForm" <%--action="/user/updateUserInformation"--%> method="post">
                         <div class="layui-form-item layui-col-xs12 layui-col-md12">
                             <label class="layui-form-label">用户名</label>
                             <div class="layui-input-inline">
                                 <input type="text" name="userName" id="userName" autocomplete="off" placeholder="用户名" class="layui-input" value="${user.username}">
                             </div>
                         </div>
                         <div class="layui-upload layui-form-item layui-col-xs12 layui-col-md12">
                             <label class="layui-form-label">头像</label>
                             <div class="layui-upload layui-input-block">
                                 <!--预览图片-->
                                 <img class="layui-upload-img" style="height: 30px;width: 30px" id="headimg" src="<%=basePath%>${user.userimg}">

                                 <button type="button" class="layui-btn" id="choose"><i class="layui-icon">&#xe67c;</i>选择文件</button>
                                 <button type="button" class="layui-btn layui-btn-warm" id="load">开始上传</button>
                                 <span id="demoText"></span>
                             </div>
                         </div>
                         <div class="layui-form-item layui-col-xs12 layui-col-md12">
                             <label class="layui-form-label">用户账号</label>
                             <div class="layui-input-inline layui-disabled">
                                 <input type="text" name="userAccount" id="userAccount"  autocomplete="off" placeholder="用户账号" class="layui-input" readonly="readonly" value="${user.useraccount}">
                             </div>
                         </div>
                         <div class="layui-upload layui-form-item layui-col-xs12 layui-col-md12">
                             <label class="layui-form-label">支付二维码</label>
                             <div class="layui-upload layui-input-block">
                                 <!--预览图片-->
                                 <img class="layui-upload-img" style="height: 30px;width: 30px" id="erimg" src="<%=basePath%>${user.userewimg}">

                                 <button type="button" class="layui-btn" id="erchoose"><i class="layui-icon">&#xe67c;</i>选择文件</button>
                                 <button type="button" class="layui-btn layui-btn-warm" id="erload">开始上传</button>
                                 <span id="erdemoText"></span></div>
                         </div>
                         <div class="layui-form-item layui-col-xs12 layui-col-md12">
                             <label class="layui-form-label">用户密码</label>
                             <div class="layui-input-inline layui-disabled">
                                 <input type="text" name="userPassword" id="userPassword"  autocomplete="off" placeholder="用户密码" class="layui-input"  value="${user.userpassword}">
                             </div>
                         </div>

                         <div class="layui-form-item layui-col-xs12 layui-col-md5">
                             <label class="layui-form-label">性别</label>
                             <div class="layui-input-inline">
                                 <input type="radio" name="userSex" value="男" title="男" <c:if test="${user.usersex=='男'}">checked</c:if>>
                                 <input type="radio" name="userSex" value="女" title="女" <c:if test="${user.usersex=='女'}">checked</c:if>>
                             </div>

                         </div>

                         <div class="layui-form-item layui-col-xs12 layui-col-md5">
                             <label class="layui-form-label">生日</label>
                             <div class="layui-input-inline">
                                 <input type="text" id="userBirth" name="userBirth"  placeholder="生日" autocomplete="off" class="layui-input" value="<fmt:formatDate value="${user.userbirth}" pattern="yyyy-MM-dd"/>">
                             </div>
                         </div>
                         <div class="layui-form-item layui-col-xs12 layui-col-md5">
                             <label class="layui-form-label">地址</label>
                             <div class="layui-input-inline">
                                 <input type="text" id="userAddress" name="userAddress"  placeholder="地址" autocomplete="off" class="layui-input" value="${user.useraddress}">
                             </div>
                         </div>
                         <div class="layui-form-item layui-col-xs12 layui-col-md5">
                             <label class="layui-form-label">电话</label>
                             <div class="layui-input-inline">
                                 <input type="text" id="userPhone" name="userPhone"  placeholder="电话" autocomplete="off" class="layui-input" value="${user.userphone}">
                             </div>
                         </div>

                         <div class="layui-form-item layui-col-xs12 layui-col-md12">
                             <label class="layui-form-label">签名</label>
                             <div class="layui-input-inline">
                                 <input placeholder="请输入签名" class="layui-textarea" id="userSign" name="userSign" value="${user.usersign}">
                             </div>
                         </div>



                         <div class="layui-form-item layui-col-xs12 layui-col-md12">
                             <div class="layui-col-md12 layui-col-md-offset1 layui-col-sm12  layui-col-sm-offset1 layui-col-xs12  layui-col-xs-offset1">
                                 <button class="layui-btn" lay-submit="" lay-filter="userSubmit">修改</button>
                             </div>
                         </div>


                     </form>
                 </div>
             </div>

         </div>


     </div>

 </div>
 <!-- 右键菜单 -->
 <!--<div class="my-dblclick-box none">
     <table class="layui-tab dblclick-tab">
         <tr class="card-refresh">
             <td><i class="layui-icon">&#x1002;</i>刷新当前标签</td>
         </tr>
         <tr class="card-close">
             <td><i class="layui-icon">&#x1006;</i>关闭当前标签</td>
         </tr>
         <tr class="card-close-all">
             <td><i class="layui-icon">&#x1006;</i>关闭所有标签</td>
         </tr>
     </table>
 </div>-->

 <script type="text/javascript" src="<%=basePath%>resources/jquery-3.2.1/jquery-3.2.1.js" ></script>
 <script src="<%=basePath%>resources/layui/layui.js"></script>
 <script src="<%=basePath%>resources/js/vip_comm.js"></script>
 <script src="<%=basePath%>resources/js/vip_table.js"></script>
 <script src="<%=basePath%>resources/js/functionList.js"></script>
 <script type="text/javascript">
     layui.use(['form', 'layer', 'rate', 'laydate', 'upload'], function () {        // 操作对象
         var layer = layui.layer;
         var element = layui.element;
         var laydate = layui.laydate;
         var form = layui.form;
         var rate = layui.rate;
         var $ = layui.jquery;
         var upload = layui.upload;
         var createTime = laydate.render({
             type: 'date',
             elem: '#createTime',//选择器结束时间
             /* min: "2018-11-01",//设置min默认最小值*/
         });


         var userBirth = laydate.render({
             type: 'date',
             elem: '#userBirth',//选择器结束时间
         });

         form.on('submit(userSubmit)', function(data){
             /*layer.alert(JSON.stringify(data.field), {
                 title: '最终的提交信息'
             });*/

             $.ajax({
                 type: "POST",
                 url: "<%=basePath%>user/updateUserInformation",
                 data: data.field,
                 success: function(data){
                     layer.msg(data.msg);
                 }
         });



             return false;
         });


         //头像上传
         var uploadInst = upload.render({
             elem: '#choose'//选择文件的DOM对象
             ,auto: false //选择文件后不自动上传
             ,bindAction: '#load' //指向一个按钮触发上传
             ,method:'POST'
             ,url: '<%=basePath%>file/imgfileUpload'
             ,choose:function(obj){//选择文件的回调，obj为选中的文件
                 //将每次选择的文件追加到文件队列
                 var files = obj.pushFile();

                 //预览选中的文件（本地文件）
                 obj.preview(function(index,file,result){
                     $('#headimg').attr('src', result);
                 });
             }
             ,before: function(obj){//文件上传前的回调

             }
             ,done: function(res){
                 console.log(">>>>>>"+JSON.stringify(res));
                 var demoText = $('#demoText');
                 demoText.html('<span style="color: #FF5722;">'+res.msg+'</span>');

                 //如果上传成功
                 if(res.code = 0){
                     return layer.msg('上传成功');
                 }
                 //上传失败
                 if(res.code != 0){
                     return layer.msg('上传失败');
                 }

             }
             ,error: function(){
                 //演示失败状态，并实现重传
                 var demoText = $('#demoText');
                 demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                 demoText.find('.demo-reload').on('click', function(){
                     uploadInst.upload();
                 });
             }
         });
         //二维码上传
         var uploadInst = upload.render({
             elem: '#erchoose'//选择文件的DOM对象
             ,auto: false //选择文件后不自动上传
             ,bindAction: '#erload' //指向一个按钮触发上传
             ,method:'POST'
             ,url: '<%=basePath%>file/erfileUpload'
             ,choose:function(obj){//选择文件的回调，obj为选中的文件
                 //将每次选择的文件追加到文件队列
                 var files = obj.pushFile();

                 //预览选中的文件（本地文件）
                 obj.preview(function(index,file,result){
                     $('#erimg').attr('src', result);
                 });
             }
             ,before: function(obj){//文件上传前的回调

             }
             ,done: function(res){
                 console.log(">>>>>>"+JSON.stringify(res));
                 var demoText = $('#erdemoText');
                 demoText.html('<span style="color: #FF5722;">'+res.msg+'</span>');

                 //如果上传成功
                 if(res.code = 0){
                     return layer.msg('上传成功');
                 }
                 //上传失败
                 if(res.code != 0){
                     return layer.msg('上传失败');
                 }

             }
             ,error: function(){
                 //演示失败状态，并实现重传
                 var demoText = $('#erdemoText');
                 demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                 demoText.find('.demo-reload').on('click', function(){
                     uploadInst.upload();
                 });
             }
         });


     });


    /**
     * 显示时间
     * */
     writeDateInfo();


 </script>

</body>
</html>
